﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AddNewArticle.ascx.cs"
    Inherits="NLLSite.Administrator.UserControl.AddNewArticle" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<%@ Register Assembly="CKFinder" Namespace="CKFinder" TagPrefix="CKFinder" %>
<script runat="server" language="C#">

    // We are not using a code behind page here just for simplicity in the
    // sample file. In this way we don't have to distribute a compiled DLL for
    // this page. In real cases, the following code will instead be defined in
    // a code behind file.

    protected override void OnLoad(EventArgs e)
    {
        CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
        _FileBrowser.BasePath = "../../ckfinder/";
        _FileBrowser.SetupCKEditor(CKEditor1);
    }

</script>
<script type="text/javascript" src="../../ckfinder/ckfinder.js"></script>
<script type="text/javascript">

    function BrowseServer() {
        // You can use the "CKFinder" class to render CKFinder in a page:
        var finder = new CKFinder();
        finder.basePath = '../../ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
        finder.selectActionFunction = SetFileField;
        finder.popup();

        // It can also be done in a single line, calling the "static"
        // popup( basePath, width, height, selectFunction ) function:
        // CKFinder.popup( '../', null, null, SetFileField ) ;
        //
        // The "popup" function can also accept an object as the only argument.
        // CKFinder.popup( { basePath : '../', selectActionFunction : SetFileField } ) ;
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileField(fileUrl) {
        document.getElementById('ctl00_ContentPlaceHolderCenter_AddNewArticle1_TxtImage').value = fileUrl;
        //Element ID = Ten class usercontrol + 1 + ID cua text box.
    }

</script>
<div class="box box-100">
    <div class="boxin">
        <div class="header">
            <h3>
                Thêm mới bài viết</h3>
        </div>
        <div style="padding: 18px;">
            <!--<form class="basic" action="" method="post" enctype="multipart/form-data"><!-- Default basic forms -->
            <div class="inner-form">
                <table>
                    <tr>
                        <td>
                            Tên Tiêu Đề :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtTitle" runat="server" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtTitle"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Image Upload :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtImage" runat="server" Width="300px"></asp:TextBox>
                            <input type="button" value="Browse" onclick="BrowseServer();" 
                                style="width: 96px" class="altbutton" />
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TxtImage"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Miêu Tả Bài Viết :
                        </td>
                        <td>
                            <asp:TextBox ID="Txtdes" runat="server" Height="70px" TextMode="MultiLine" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Txtdes"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Nội dung :
                        </td>
                        <td>
                            <CKEditor:CKEditorControl ID="CKEditor1" runat="server" Width="600px"></CKEditor:CKEditorControl>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="CKEditor1"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Tác Giả :
                        </td>
                        <td>
                            <asp:ListBox ID="LbxAut" runat="server" DataSourceID="LinqDataSource2" DataTextField="AuthorName"
                                DataValueField="ID" Width="250px"></asp:ListBox>
                            <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="DAL_Class.NLLDataContext"
                                TableName="Authors">
                            </asp:LinqDataSource>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Chọn Menu :</td>
                        <td>
                            <asp:DropDownList ID="Ddlposi" runat="server" Width="250px" AutoPostBack="True" 
                                onselectedindexchanged="Ddlposi_SelectedIndexChanged">
                                <asp:ListItem>Top</asp:ListItem>
                                <asp:ListItem Value="Chủ Đề">Chủ Đề</asp:ListItem>
                                <asp:ListItem Value="Hội Thảo">Hội Thảo</asp:ListItem>
                            </asp:DropDownList>
                            <br />
                            <asp:ListBox ID="lbxMenu" runat="server" DataTextField="Name"
                                DataValueField="ID" Height="64px" Width="250px" 
                                ></asp:ListBox>
                            <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                                ContextTypeName="DAL_Class.NLLDataContext" TableName="View_Menu_Articles" 
                                Select="new (ID, Name)" Where="Position == @Position">
                                <WhereParameters>
                                    <asp:ControlParameter ControlID="Ddlposi" DefaultValue="Top" Name="Position" 
                                        PropertyName="SelectedValue" Type="String" />
                                </WhereParameters>
                            </asp:LinqDataSource>
                            <asp:LinqDataSource ID="LinqDataSource3" runat="server" 
                                ContextTypeName="DAL_Class.NLLDataContext" Select="new (ID, Name)" 
                                TableName="Menus" Where="Position == @Position">
                                <WhereParameters>
                                    <asp:Parameter DefaultValue="Chủ Đề" Name="Position" Type="String" />
                                </WhereParameters>
                            </asp:LinqDataSource>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Hiển thị trên Trang chủ :
                        </td>
                        <td>
                            <asp:CheckBox ID="CbxFront" runat="server" />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            Cho vào Video:&nbsp;
                            <asp:CheckBox ID="CbxSlide" runat="server" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            MetaTitle :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtMetatit" runat="server" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="TxtMetatit"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            MetaDescription :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtMetades" runat="server" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="TxtMetades"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            MetaKeywords :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtMetakey" runat="server" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="TxtMetakey"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            MetaRobots :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtMetaro" runat="server" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="TxtMetaro"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            MetaAuthor :
                        </td>
                        <td>
                            <asp:TextBox ID="TxtMetaAut" runat="server" Width="400px"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="TxtMetaAut"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <asp:Label ID="Lblchk" runat="server" CssClass="style1"></asp:Label>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <asp:Button ID="BtnAdd" runat="server" Text="Thêm mới " OnClick="BtnAdd_Click" 
                                CssClass="altbutton" />
                            <asp:Button ID="Button2" runat="server" Text="Thiết Lập Lại" 
                                OnClick="Button2_Click" CssClass="altbutton" />
                                <a href="QuanlyBaiViet.aspx"><input type="button" value="Quay về trang quản lý" class="altbutton" /></a> 
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
